The present invention relates generally to software systems, and, more particularly, to communication between modules in a software system.
Software systems often consist of a number of independent modules, otherwise referred to as components or processes, etc. The modules comprising the system may be part of the same address space or may be partitioned across different address spaces. Each module typically consists of one or more threads. Modules, although independent of each other, often need to exchange data and control events so that they can work together in concert. Two well known methods for communication between modules are the use of procedure calls and message passing.
Procedure calls can be used when modules are in the same address space. The advantage of procedure calls is simplicity and efficiency. Procedure calls, however, are unsuitable in many situations. The use of procedure calls to effect event exchange between modules causes unnecessarily tight coupling among modules. Procedure calls have to be resolved at build time and therefore modules cannot be easily added or removed from the system. Moreover, the synchronous nature of the procedure call mechanism implies that events are processed in the context of the calling module leading to temporal coupling between event generating and consuming modules. This is undesirable in real-time embedded systems since a higher priority activity in a module can miss its deadline if it calls procedures in an unrelated module. In addition, procedure calls are unsuitable when multiple modules are required to consume an event, or when the sending module cannotxe2x80x94or need notxe2x80x94know which other modules need to see the event. An alternative to procedures statically linked at compile time are dynamically linked libraries (xe2x80x9cDLLsxe2x80x9d). Although DLLs allow procedures to be updated after compile time, they do not allow the fundamental interconnection between modules to be modified after compile time. In addition, the other difficulties associated with procedures described above remain.
An alternative is to use message queues per module to decouple the sending module from the receiving module. However, simple message passing creates its own problems. The sender has to know the address of the receiver to send messages to the appropriate receive queue. Having a single queue per receiver, can cause priority inversion because higher priority messages could be queued behind low priority ones in the receiver""s message queue. In addition, most message passing implementations copy data twicexe2x80x94once from the sender to an intermediate buffer and once more from the buffer to the receiver. Since memory copies are expensive, this can cause performance problems, especially in resource-limited environments such as embedded systems.
One could use more sophisticated forms of message passing based on ideas such as remote procedure calls, remote method invocations, and distributed object technology. However, all of these are meant for large applications that are distributed on multiple machines. These systems are meant to scale to large applications and have a lot of heavyweight mechanisms. These systems, in short, impose too much overhead for embedded systems and resource constrained environments.
An event exchange mechanism is disclosed that utilizes a receiver-driven, publisher-subscriber model to overcome various problems in the prior art. The event exchange has a flexible addressing scheme so that a sending module need not be aware of its receiving modules. In addition, the event exchange provides the ability to multicast messages to interested receivers. Mechanisms for flow control are also provided so that a receiver can exert backpressure on a sender, which is especially useful for the transfer of multimedia data. The system provides a uniform mechanism for control and data exchange.
In one aspect of the present invention, the idea of xe2x80x9cblindcastingxe2x80x9d is adapted and utilized to address individual software modules. A sending module need not be aware of its receivers and merely posts an event at a sending port, and the event exchange delivers the event to one or more receiving ports. The event exchange enables arbitrary inter-connections between the modules. It supports one-to-many and many-to-one communication. Furthermore, moving the inter-connection of modules to the event exchange has the advantage of permitting the fundamental inter-connection of modules in a system to be modified after compile time. Zero-copy reference count-based mechanisms can be utilized for efficiency. In one embodiment of the invention, the connectivity between ports of different modules is specified in a connection table; in another, smart modules may be utilized to ascertain and establish the connectivity; in yet another, one or more modules may be responsible for establishing connections between modules.